package com.ydgk.service.impl;

import com.ydgk.bean.FurnitureKinds;
import com.ydgk.dao.FurnitureKindsMapper;
import com.ydgk.dao.Pre_orderMapper;
import com.ydgk.service.FurnitureKindsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FurnitureKindsServiceImpl implements FurnitureKindsService{
    @Autowired
    private FurnitureKindsMapper furnitureKindsMapper;

    @Autowired
    private Pre_orderMapper pre_orderMapper;

    public int insert(FurnitureKinds furnitureKinds) {
        return furnitureKindsMapper.insert(furnitureKinds);
    }

    public List<FurnitureKinds> findByFid(int fid) {
        return furnitureKindsMapper.findByFid(fid);
    }

    public FurnitureKinds findById(int fkid) {
        return furnitureKindsMapper.findById(fkid);
    }

    public int updateById(FurnitureKinds furnitureKinds) {
        return furnitureKindsMapper.updateById(furnitureKinds);
    }

    public int deleteById(int fkid) {
        int count = pre_orderMapper.findCountByFkid(fkid);
        if(count > 0){
            return 0;
        }else {
            return furnitureKindsMapper.deleteByFkid(fkid);
        }
    }
}
